import os
import pygame

pygame.init()
screen = pygame.display.set_mode([800, 600])

keep_going = True
x = 0
y = 100

timer = pygame.time.Clock()
headPic = pygame.image.load(f"{os.path.dirname(__file__)}/xb.jpg")
headWid = headPic.get_width()

while keep_going:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            keep_going = False
    x += 1
    if x > 800-headWid:
        x = 0
    screen.fill((0, 0, 0))
    screen.blit(headPic, (x, y))
    pygame.display.update()

pygame.quit()